/**
 * 
 */
package com.lion.jacoco.web.home.module.action.config;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.service.form.Group;
import com.alibaba.citrus.turbine.Navigator;
import com.alibaba.citrus.turbine.dataresolver.FormGroup;
import com.lion.jacoco.dao.dataobject.AppConfigDO;
import com.lion.jacoco.manager.AppManager;

/**
 * AppConfigAction.java. 2011-12-1上午10:55:58 @author LionBule.
 */
public class AppConfigAction {
    @Autowired
    private AppManager appManager;

    public void doAdd(@FormGroup("addAppConfig") Group group, Navigator nav) {
        AppConfigDO pdata = new AppConfigDO();
        group.setProperties(pdata);
        
        try {
            appManager.addApp(pdata);
            nav.redirectTo("homeModule").withTarget("homepage.vm");
        } catch (Exception e) {
            group.getField("appName").setMessage("systemError");
        }
    }
    
    public void doUpdate(@FormGroup("updateAppConfig") Group group, Navigator nav) {
        AppConfigDO pdata = new AppConfigDO();
        group.setProperties(pdata);
        try {
            appManager.updateAppById(pdata);
            nav.redirectTo("homeModule").withTarget("homepage.vm");
        } catch (Exception e) {
            group.getField("appName").setMessage("systemError");
        }
    }

}
